﻿function UserTypeChange()
{
    var selectvalue  = $("#drpUserType option:selected").val();
    switch(selectvalue)
    {
        case "Z":
        case "A":
            $("#drpG").attr("disabled",true);
            $("#drpG").attr("value","0");
            $("#drpG").attr("text","");
            $("#drpU").attr("disabled",true);
            $("#drpU").attr("value","0");
            $("#drpU").attr("text","");
        break;
        case "G":
            $("#drpG").attr("disabled",false);
            $("#drpU").attr("disabled",true);
            $("#drpU").attr("value","0");
            $("#drpU").attr("text","");
        break;
        case "U":
        case "P":
             $("#drpG").attr("disabled",false);
             $("#drpU").attr("disabled",false);
        break;
        default:
        break;
    }
}

function selectItem()
{
    if($(this).attr("checked"))
       document.getElementById("hiddenSelected").value= $("#hiddenSelected").attr("value")+$(this).attr("value")+",";
    else
         document.getElementById("hiddenSelected").value= document.getElementById("hiddenSelected").value.replace($(this).attr("value")+",","");
}

function selectAll() {
    var checked = $("#headercheck").attr("checked");
    $(".itemCheckBox").each(function() {
      $(this).attr("checked",checked);
      if($(this).attr("checked"))
       document.getElementById("hiddenSelected").value= $("#hiddenSelected").attr("value")+$(this).attr("value")+",";
    else
         document.getElementById("hiddenSelected").value= document.getElementById("hiddenSelected").value.replace($(this).attr("value")+",","");
    });
} 

function getCopyValue()
{
    var source  = $(this);
    var tag = $("#"+$(this).attr("id")+"_H");
    tag.attr("value",source.attr("value"));
}

function comparePassword()
{
    var newP = $("#txtPasswordNew_H").attr("value");
    var confirmP = $("#txtPasswordNewConfirm_H").attr("value");
    if(newP.length == 0 || confirmP .length == 0)
    {
        alert("新密码不能为空.");
        return false;
    }
    if(newP ==confirmP)
    {
        return true;
    }
    else
    {
        alert("密码不一致,请重新输入.");
        $("#txtPasswordNewConfirm_H").attr("value","");
        $("#txtPasswordNew_H").attr("value","");
        $("#txtPasswordNewConfirm").attr("value","");
        $("#txtPasswordNew").attr("value","");
        return false;
    }
}

function ShowLineItemList(obj) {
    if (obj.className == "querytree_collaspe") {
        obj.className = "querytree_expand";
        $("#" + obj.id + "_tr").fadeIn("slow");
    }
    else {
        obj.className = "querytree_collaspe";
        $("#" + obj.id + "_tr").fadeOut("slow");
    }
}

function ConfimDelete() {
    if (confirm("您是否要删除这条数据?")) {
        return true;
    }
    else {
        return false;
     }
 }

 function AlertDataSave(URL) {
     alert("数据保存成功");
     window.location = URL;
 }

function getBirthday() {
    var Birthday = $("#hiddentxtBirthday");
    var IDCard = $("#txtIDCard");
    //if (Birthday.val().length == 0) {
        if (IDCard.val() != "" && IDCard.val().length == 18) {
            Birthday.val(IDCard.val().substr(6, 4) + "-" + IDCard.val().substr(10, 2)); //+ "-" + IDCard.val().substr(12, 2)
        }
        else if (IDCard.val() != "" && IDCard.val().length == 15) {
            Birthday.val("19" + IDCard.val().substr(6, 2) + "-" + IDCard.val().substr(8, 2)); //+ "-" +IDCard.val().substr(10, 2)
        }
    //}
    //alert(Birthday.val());
} 

